<template>
  <div>
    <Card dis-hover>
      <Row class="card-title" type="flex" justify="space-between">
        <Col>商品供货信息</Col>
        <Row type="flex" justify="space-between">
          <!-- <a @click.prevent="save" v-if="isSave" style="margin-right: 20px;margin-left: 20px;">保存</a> -->
          <el-button
            v-preventReClick
            type="text"
            size="large"
            :loading="saveBtnLoading"
            class="save-btn"
            @click="save"
            >保存</el-button
          >
        </Row>
      </Row>
      <Row type="flex" style="padding-top: 20px">
        <Col span="4" style="margin-right: 30px">状态：待完善</Col>
        <Col span="6" style="margin-right: 30px"
          >管理区域：{{ topInfo.manageArea || "" }}</Col
        >
        <Col span="10">商品名称：{{ topInfo.productName || "" }}</Col>
      </Row>
      <div
        v-if="
          topInfo.isSaleMultiUnit == '1' || topInfo.isPurchaseMultiUnit == '1'
        "
      >
        <gongyinsteel
          ref="gong"
          :topinfo="topInfo"
          :productUuid="prouuid"
          @updateLoadingState="updateLoadingState"
        />
      </div>
      <div v-else>
        <gongyin
          ref="gong"
          :topinfo="topInfo"
          :productUuid="prouuid"
          @updateLoadingState="updateLoadingState"
        />
      </div>
    </Card>
  </div>
</template>

<script>
import bus from '@/mixins/bus';
import { ApiRequest } from '@api/basePage';
import util from '@/libs/util';
import gongyin from '@/components/commodity/addSupplyInfo/initAddSupply';
import gongyinsteel from '@/components/commodity/addSupplyInfo/initAddSupplySteel';

export default {
  name: 'gonghuoxinxi',
  components: {
    gongyin,
    gongyinsteel
  },
  data () {
    return {
      saveBtnLoading: false,
      isSave: true,
      topInfo: {
        isSaleMultiUnit: '',
        isPurchaseMultiUnit: ''
      },
      prouuid: ''
    };
  },
  mounted () {},
  created () {
    let that = this;
    bus.$on('gonghuo_success', function (val) {
      that.isSave = false;
      that.$forceUpdate();
    });
  },
  methods: {
    getDefaultData (e) {
      this.prouuid = util.Pub.getStorageSync('productUuid');
      if (this.prouuid == null || this.prouuid == undefined) {
        this.$Message.error('请先填写基本信息');
        return;
      }
      let data = {
        productUuid: this.prouuid
      };
      ApiRequest(
        '/sysback/supplyproductrel/getTopInfo',
        'post',
        data,
        true
      ).then(res => {
        this.topInfo = res.retData;
      });
    },
    save () {
      this.$refs.gong.save();
    },
    submit () {
      this.$refs.gong.submit();
    },
    updateLoadingState (state) {
      this.saveBtnLoading = state;
    }
  }
};
</script>

<style lang="less" scoped>
.save-btn {
  margin-top: 10px;
}
.card-title {
  font-size: 16px;
  color: #17233d;
  font-weight: 500;
  height: 50px;
  line-height: 50px;
  margin-top: -16px;
  border-bottom: 1px solid #e8eaec;
}
</style>
